<template>
  <view :style="{height : pageHeight + 'px'}" class="content">
    <tui-loading v-if="loadingTips" :isMask="true"></tui-loading>
    <view v-if="logisticsList.length>0" class="logisticsList">
      <view class="title">
        后勤保障人员
      </view>
      <view v-for="(item,index) in logisticsList" :key="index" class="logisticsItem">
        <view v-if="item.job === 2" class="memberTag">
          领队
        </view>
        <view v-else-if="item.job === 3" class="memberTag">
          医疗员
        </view>
        <view v-else class="memberTag">
          安全员
        </view>
        <image mode="aspectFit" src="https://echengtuhua.oss-cn-shenzhen.aliyuncs.com/passengerIcon.png"
               style="margin: 0rpx 10rpx;width: 30rpx;height: 30rpx;"></image>
        <view class="logisticsName">
          {{ item.name }}
        </view>
        <view class="phone">
          <image mode="aspectFit" src="https://echengtuhua.oss-cn-shenzhen.aliyuncs.com/phoneIcon.png">
          </image>
          {{ item.tel }}
        </view>
      </view>
    </view>
    <view v-else style="margin: 0 auto; color: darkgray;">
      暂无数据
    </view>
  </view>
</template>

<script>
import {
  getLogistics
} from '@/api/tourplan.js'

export default {
  data() {
    return {
      pageHeight: 750,
      loadingTips: false, //加载提示
      itineraryId: 0, //行程id
      logisticsList: []
    }
  },
  onLoad: function (options) {
    const that = this
    uni.getSystemInfo({
      success: function (res) {
        that.pageHeight = res.windowHeight
      }
    })
    that.loadingTips = true, //加载提示
        that.initData(options)
  },
  methods: {
    //初始化数据
    initData(options) {
      const that = this
      //获取行程id
      that.itineraryId = options.itineraryId
      that.getLogMember()
    },
    //根据路线行程查询对应的后勤人员
    getLogMember() {
      const that = this
      getLogistics({
        itineraryId: that.itineraryId
      }).then(res => {
        Object.keys(res).forEach((key) => {
          that.logisticsList.push(res[key][0])
        });
        that.loadingTips = false //关闭加载提示
      }).catch(err => {
        that.loadingTips = false //关闭加载提示
        uni.showToast({
          title: err,
          icon: 'none',
          duration: 3000
        })
        console.log(err)
      })
    }
  }
}
</script>

<style>
@import url('logistics.css');
</style>
